/* 
 * File:   Pool.hpp
 * Author: bd
 *
 * Created on March 27, 2011, 2:49 PM
 */

#ifndef POOL_HPP
#define	POOL_HPP
#include <map>
#include "Queue.hpp"

template <typename T>
class Pool {
public:

    enum QueueType {
        INPUT_QUEUE, OUTPUT_QUEUE, FAILOVER_QUEUE
    };
public:

    Pool() {
        typename Queue<T>::QueuePtr ptr(new Queue<T>);
        queues_[INPUT_QUEUE] = ptr;

        ptr.reset(new Queue<T>);
        queues_[OUTPUT_QUEUE] = ptr;

        ptr.reset(new Queue<T>);
        queues_[FAILOVER_QUEUE] = ptr;
    }

    typename Queue<T>::QueuePtr inputQueue() {
        return queues_[INPUT_QUEUE];
    }

    typename Queue<T>::QueuePtr outputQueue() {
        return queues_[OUTPUT_QUEUE];
    }

    typename Queue<T>::QueuePtr failoverQueue() {
        return queues_[FAILOVER_QUEUE];
    }

    bool empty() {
        if (inputQueue()->size() == 0 &&
                failoverQueue()->size() == 0 &&
                outputQueue()->size() == 0)
            return true;
        else
            false;
    }

private:
    std::map<QueueType, typename Queue<T>::QueuePtr > queues_;
};

#endif	/* POOL_HPP */

